<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 韩金龙
  Date: 2021/11/23
  Time: 8:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.8.2.min.js"></script>
    <link rel="stylesheet" href="css/css.css">
    <link rel="stylesheet" href="css/img.css">
</head>
<body>
    <form action="list.do">
        <input type="hidden" name="pageNum">
    </form>
    <table>
        <tr>
            <td>编号</td>
            <td>地区</td>
            <td>图片</td>
            <td>省</td>
            <td>市</td>
            <td>县</td>
            <td>
                操作
                <button onclick="addTo()">添加</button>
            </td>
        </tr>
        <c:forEach items="${pageInfo.list}" var="li">
            <tr>
                <td>${li.id}</td>
                <td>${li.title}</td>
                <td>
                    <img src="${li.pic}" alt="无法显示" width="50px">
                </td>
                <td>${li.shengName}</td>
                <td>${li.shiName}</td>
                <td>${li.xianName}</td>
                <td>
                    <button onclick="updTo(${li.id})">修改</button>
                </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="20">
                <button onclick="fy(1)">首页</button>
                <button onclick="fy(${pageInfo.isFirstPage?1:pageInfo.prePage})">上页</button>
                <button onclick="fy(${pageInfo.isLastPage?pageInfo.pages:pageInfo.nextPage})">下页</button>
                <button onclick="fy(${pageInfo.pages})">尾页</button>
                第${pageInfo.pageNum}/${pageInfo.pages}页
            </td>
        </tr>
    </table>
</body>
<script>
    function fy(pageNum) {
        $("[name='pageNum']").val(pageNum)
        $("form").submit()
    }
    function addTo() {
        location="addTo.do"
    }
    function updTo(id) {
        location="updTo.do?id="+id
    }
</script>
</html>
